/*
 * uart suspend and resume for serial port
 *
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019.
 * Description: add uart suspend and resume for serial port
 * Author: zhangwen
 * Create: 2019-06-11
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */
#ifndef _UART_SUSPEND_DRV_H_
#define _UART_SUSPEND_DRV_H_

#define UART_RESUME 		0
#define UART_SUSPEND		1
#define UART_SUSPEND_RX 	2
#define UART_SUSPEND_TX 	3
#define UART_SW_SUSPEND 	4

struct uart_suspend_ops {
	const struct uart_ops *(*serial_get_pops)(void);
	struct uart_port *(*serial_get_console_port)(void);
	struct uart_driver *(*serial_get_drv)(void);
};

extern atomic_t g_uart_suspend;
extern long tty_uart_suspend;
extern long tty_suspend_index;
extern struct uart_suspend_ops serial_suspend_ops;

extern bool is_rx_suspend(struct uart_port *port);
extern bool is_tx_suspend(struct uart_port *port);
extern int is_uart_suspend(void);
extern void resume_uart(void);
extern void suspend_uart(void);
extern void suspend_rx(void);
extern void resume_rx(void);
extern void suspend_tx(void);
extern void resume_tx(void);
extern void uart_clear_xmit_ring(struct uart_port *port);
extern void uart_suspend_init(void);
extern bool is_uart_suspend_initialized(void);
extern void rm_uart(void);

#if defined(CONFIG_SERIAL_AMBA_PL011) || defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE)
extern const struct uart_ops *serialpl011_get_pops(void);
extern struct uart_port *serialpl011_get_console_port(void);
extern struct uart_driver *serialpl011_get_drv(void);
extern void serialpl011_uart_suspend_register(void);
#endif

#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
extern const struct uart_ops *serial8250_get_pops(void);
extern struct uart_port *serial8250_get_console_port(void);
extern struct uart_driver *serial8250_get_drv(void);
extern void serial8250_uart_suspend_register(void);
#endif

#if defined(CONFIG_SERIAL_STM32) || defined(CONFIG_SERIAL_STM32_CONSOLE)
extern const struct uart_ops *serialstm32_get_pops(void);
extern struct uart_port *serialstm32_get_console_port(void);
extern struct uart_driver *serialstm32_get_drv(void);
extern void serialstm32_uart_suspend_register(void);
#endif

#endif /* _UART_SUSPEND_DRV_H_ */
